<template>
	<view class="container">
		<view class="head y_center">
			<view class="avatar">
				<image :src="info.user.avatar" mode=""></image>
			</view>
			<view class="nikename">
				{{info.user.student_no}}
			</view>
		</view>
		<view class="content">
			<view class="title">
				{{info.shop.name}}
			</view>
			<view class="jigou">
				<text>{{info.shop.name}}</text>
			</view>
			<view class="shijian">
				<image src="../../static/icon/shijian2.png" mode=""></image>
				<text>{{info.spec}}</text>
			</view>
			<view class="local">
				<image src="../../static/icon/dizhi-3@2x.png" mode=""></image>
				<text>{{info.shop.address}}</text>
			</view>
			<view class="jine">
				¥{{info.total_price}}
			</view>
		</view>
		<view class="tuijian y_center">
			<text>推荐老师</text>
			<input type="text" v-model="teacherId" placeholder="请输入推荐老师ID" placeholder-class="pla_class"/>
		</view>
		<view class="total_price xy_center_between">
			<text>总金额</text>
			<text>¥{{info.total_price}}</text>
		</view>
		<view class="notice">
			温馨提示：如需开具收据，请联系校区
		</view>
		<view class="pay">
			<view class="shifu">
				实付金额：<text>¥{{info.total_price}}</text>
			</view>
			<view class="payBtn" @click="pay()">
				提交订单
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				token:'',
				orderNo:'',
				info:'',
				teacherId:'',
			}
		},
		onLoad(option) { 
			this.orderNo = option.id;
			uni.getStorage({
				key: 'user_info',
				success: (res) => {
					this.token = res.data.token;
					this.getInfo()
				},
				fail() {
					uni.redirectTo({
						url: '../login/auth'
					});
				}
			});
		},
		methods:{
			getInfo(){
				this.$request('/api/wxapp/v2/order/index/takeOrderDetail',{
					token:this.token,
					"order_no":this.orderNo
				}).then(res=>{
					if(res.code===1){
						this.info = res.data;
					}
				})
			},
			pay(){
				if(this.teacherId){
					this.$request('/api/wxapp/v2/order/index/saveRecommend',{
						"token":this.token,
						"order_no":this.orderNo,
						"recommend":this.teacherId
					}).then(res=>{
						if(res.code===1){
							uni.redirectTo({
								url: './index?order=' + this.orderNo
							});
						}
					})
				}else{
					uni.redirectTo({
						url: './index?order=' + this.orderNo
					});
				}
				
			}
		}
	}
</script>

<style scoped lang="scss">
	.container{
		background-color: #F6F6F6;
	}
	.head{
		height: 176rpx;
		background-color: #FFFFFF;
		padding-left: 40rpx;
	}
	.avatar,.avatar image{
		width: 48px;
		height: 48px;
		border-radius: 50%;
	}
	.nikename{
		font-size: 20px;
		font-weight: 700;
		color: #666666;
		margin-left: 10px;
	}
	.content{
		background-color: #FFFFFF;
		padding: 40rpx;
		box-sizing: border-box;
		margin-top: 10px;
		.title{
			font-size: 16px;
			font-weight: 500;
			color: #333333;
		}
		.jigou{
			margin-top: 15rpx;
			text {
				display: inline-block;
				padding: 4px 2px 3px 2px;
				background: #FFFFFF;
				border-radius: 2px;
				border: 1px solid #66A8A0;
				font-size: 12px;
				line-height: 12px;
				color: #66A8A0;
			}
		} 
		.shijian,.local{
			display: flex;
			flex-direction: row;
			align-items: center;
			font-size: 13px;
			color: #666666;
			margin-top: 15rpx;
			text{
				margin-left: 10rpx;
			}
		}
		.shijian{
			margin-top: 50rpx;
		}
		.shijian image{
			width: 13px;
			height: 13px;
		}
		.local image{
			width: 12px;
			height: 15px;
		}
		.jine{
			font-size: 18px;
			font-weight: 700;
			color: #333333;
			text-align: right;
			margin-top: 60rpx;
		}
	}
	.tuijian{
		height: 56px;
		background: #FFFFFF;
		margin: 10px 0;
		padding-left: 20px;
		input{
			margin-left: 10px;
		}
	}
	/deep/ .pla_class{
		font-size: 15px;
		color: #C3C3C3;
	}
	.total_price{
		height: 112rpx;
		padding: 0 20px;
		background-color: #FFFFFF;
		text:nth-child(1){
			font-size: 16px;
			color: #666666;
		}
		text:nth-child(2){
			font-size: 18px;
			font-weight: 700;
			color: #333333;
		}
	}
	.notice{
		font-size: 13px;
		color: #999999;
		line-height: 20px;
		margin-top: 10px;
		margin-left: 18px;
	}
	.pay{
		width: 750rpx;
		height: 112rpx;
		background-color: #FFFFFF;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		position: fixed;
		left: 0;
		bottom: 0;
		padding: 0 40rpx;
		box-sizing: border-box;
		.shifu{
			font-size: 13px;
			color: #999999;
			text{
				font-size: 18px;
				font-weight: 500;
				color: #ED6A2A;
			}
		}
		.payBtn{
			width: 234rpx;
			height: 72rpx;
			line-height: 72rpx;
			background: linear-gradient(90deg, #FF5B2D 0%, #FD5629 100%);
			border-radius: 36rpx;
			font-size: 15px;
			color: #FFFFFF;
			text-align: center;
		}
	}
</style>
